<template>
  <el-config-provider :locale="currentLocale">
    <router-view />
    <ReDialog />
    <!-- 全局的 DrawerManager -->
    <DrawerManager ref="drawerManager" />
  </el-config-provider>
</template>

<script lang="ts">
import { defineComponent, provide, ref } from "vue";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import { ReDialog } from "@/components/ReDialog";
import DrawerManager from "@/components/common/DrawerManager.vue";

export default defineComponent({
  name: "app",
  components: {
    [ElConfigProvider.name]: ElConfigProvider,
    ReDialog,
    DrawerManager
  },
  setup() {
    // 定义抽屉管理器的逻辑
    const drawerManager = ref(null);
    const drawer = {
      open: options => drawerManager.value.open(options),
      close: () => drawerManager.value.close()
    };
    provide("drawer", drawer);
    return {
      drawerManager
    };
  },
  computed: {
    currentLocale() {
      return zhCn;
    }
  }
});
</script>
